package com.bw.router.routerUtils

import android.content.Context
import com.alibaba.android.arouter.facade.Postcard
import com.alibaba.android.arouter.facade.callback.NavigationCallback
import com.alibaba.android.arouter.launcher.ARouter
import com.blankj.utilcode.util.ToastUtils

class ARouterUtils:NavigationCallback {
    override fun onFound(postcard: Postcard?) {}

    override fun onLost(postcard: Postcard?) {
        ToastUtils.showLong("找不到路径:${postcard?.path}")
        postcard?.context.let {
            ARouter.getInstance().build("/app/NotFoundActivity").navigation()
        }
    }

    override fun onArrival(postcard: Postcard?) {}

    override fun onInterrupt(postcard: Postcard?) {}

    object ARouterManger{
        fun navigation(context:Context,path:String,key:String?="",para:String?=""){
            ARouter.getInstance().build(path).withString(key,para).navigation(context,ARouterUtils())
        }
    }
}